package cn.tedu.imop.basic.service.impl;

import cn.tedu.imop.basic.dao.repository.MemberRepository;
import cn.tedu.imop.basic.entity.Member;
import cn.tedu.imop.basic.service.MemberService;
import cn.tedu.imop.common.pojo.PageData;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Primary
@Service
public class MemberServiceImpl implements MemberService {
    private final MemberRepository memberRepository;
    public MemberServiceImpl(MemberRepository memberRepository) {
        this.memberRepository = memberRepository;
    }

    @Override
    public Boolean createMember(Member member) {
        member.setIpAddress("127.0.0.1");
        member.setUnionId(UUID.randomUUID().toString());
        memberRepository.insertMember(member);
        return true;
    }

    @Override
    public PageData<Member> getMemberList(Member member) {
        return memberRepository.selectMemberList(member);
    }
}
